// 返回顶部
var returnTop = document.querySelector(".return_top");
var timer =0;

returnTop.addEventListener("mouseenter",function(){
    returnTop.style.backgroundImge="url(../images/返回顶部图标1.png) no-repeat center"
    returnTop.style.opacity="0.2"
})
returnTop.addEventListener("mouseleave",function(){
    returnTop.style.backgroundImge="url(../images/返回顶部图标.png) no-repeat center"
    returnTop.style.opacity="1"
})
returnTop.addEventListener("click",function(){
        timer = setInterval(function(){
            
            
            var scrollTop = document.documentElement.scrollTop 
            var ySpeed = Math.sqrt(scrollTop);
            document.documentElement.scrollTop = document.body.scrollTop = scrollTop - ySpeed;
            if(scrollTop == 0){
                clearInterval(timer);
                returnTop.style.backgroundPositionY="-50px"
                
            } 
        },10);
    });
window.onscroll=function(){   
    var scrollTop=document.documentElement.scrollTop;
    if(scrollTop > 0){
        returnTop.style.backgroundPositionY="0px"
    }
}